package com.itheima.stock.Thread;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Pool {
    public static void main(String[] args) throws InterruptedException {
        //创建线程池(线程无限多)
        ExecutorService executorService = Executors.newCachedThreadPool();
        //创建线程池(线程有限制)
        ExecutorService executorService1 = Executors.newFixedThreadPool(3);
        executorService1.submit(new MyThread());
        executorService1.submit(new MyThread());
        executorService1.submit(new MyThread());
        executorService1.submit(new MyThread());
        executorService1.submit(new MyThread());

        //线程池关闭
       // executorService.shutdown();

    }
    public static class MyThread implements Runnable {
        public void run()
        {
            for (int i = 0; i <= 100; i++) {
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }
    }
}
